package com.saas.datasource.example.dao;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.saas.datasource.core.annotation.DSParam;
import com.saas.datasource.core.annotation.DataSourceAnnotation;
import com.saas.datasource.example.entity.Test;
import com.saas.datasource.example.mapper.TestMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * TestDAO层服务类
 * </p>
 *
 * @author xhou
 * @since 2020-12-22
 */
@Service
public class TestDAO {
    @Autowired
    private TestMapper baseMapper;

    @DataSourceAnnotation("master")
    public int insert(@DSParam("ds") String ds, Test entity){
       return baseMapper.insert(entity);
    };

    @DataSourceAnnotation("master")
    public int deleteById(@DSParam("ds") String ds,Long id){
        return baseMapper.deleteById(id);
    };

    @DataSourceAnnotation("master")
    public int deleteByMap(@DSParam("ds") String ds, Map<String, Object> columnMap){
        return baseMapper.deleteByMap(columnMap);
    };

    @DataSourceAnnotation("master")
    public int delete( @DSParam("ds") String ds,Wrapper<Test> wrapper){
        return baseMapper.delete(wrapper);
    };

    @DataSourceAnnotation("master")
    public  int deleteBatchIds(@DSParam("ds") String ds, Collection<? extends Serializable> idList){
        return baseMapper.deleteBatchIds(idList);
    };

    @DataSourceAnnotation("master")
    public int updateById(@DSParam("ds") String ds,Test entity){
        return baseMapper.updateById(entity);
    };

    @DataSourceAnnotation("master")
    public int update(@DSParam("ds") String ds,Test entity, Wrapper<Test> updateWrapper){
        return baseMapper.update(entity,updateWrapper);
    };

    @DataSourceAnnotation("master")
    public Test selectById(@DSParam("ds") String ds,Long id){
        return baseMapper.selectById(id);
    };

    @DataSourceAnnotation("master")
    public List<Test> selectBatchIds(@DSParam("ds") String ds, Collection<? extends Serializable> idList){
        return baseMapper.selectBatchIds(idList);
    };

    @DataSourceAnnotation("master")
    public List<Test> selectByMap(@DSParam("ds") String ds, Map<String, Object> columnMap){
        return baseMapper.selectByMap(columnMap);
    };

    @DataSourceAnnotation("master")
    public Test selectOne(@DSParam("ds") String ds, Wrapper<Test> queryWrapper){
        return baseMapper.selectOne(queryWrapper);
    };

    @DataSourceAnnotation("master")
    public Integer selectCount(@DSParam("ds") String ds, Wrapper<Test> queryWrapper){
        return baseMapper.selectCount(queryWrapper);
    };

    @DataSourceAnnotation("master")
    public List<Test> selectList(@DSParam("ds") String ds, Wrapper<Test> queryWrapper){
        return baseMapper.selectList(queryWrapper);
    };

    @DataSourceAnnotation("master")
    public List<Map<String, Object>> selectMaps(@DSParam("ds") String ds, Wrapper<Test> queryWrapper){
        return baseMapper.selectMaps(queryWrapper);
    };

    @DataSourceAnnotation("master")
    public List<Object> selectObjs(@DSParam("ds") String ds, Wrapper<Test> queryWrapper){
        return baseMapper.selectObjs(queryWrapper);
    };

    @DataSourceAnnotation("master")
    public <E extends IPage<Test>> E selectPage(@DSParam("ds") String ds, E page, Wrapper<Test> queryWrapper){
        return baseMapper.selectPage(page,queryWrapper);
    };

    @DataSourceAnnotation("master")
    public <E extends IPage<Map<String, Object>>> E selectMapsPage(@DSParam("ds") String ds, E page,Wrapper<Test> queryWrapper){
        return baseMapper.selectMapsPage(page,queryWrapper);
    };
}
